#!/usr/bin/env python
# coding: utf-8

import numpy as np

from sklearn.metrics import mean_squared_error as mse#均方误差
from sklearn.metrics import mean_absolute_error as mae #平方绝对误差
from sklearn.metrics import r2_score as R#R square
def RMSE(y_true, y_pred):
    RMSE = mse(y_true,y_pred)**0.5
    return RMSE
def MAE(y_true, y_pred):  
    MAE = mae(y_true,y_pred)
    return MAE
def  MAPE(y_true, y_pred):
    n = len(y_true)
    MAPE = np.mean(abs((y_true - y_pred)/y_true))*100
    return MAPE
def R_square(y_true, y_pred):
    R_square = R(y_true, y_pred) 
    return R_square
def sMAPE(A,F):
    return 100/len(A)*sum(2*abs(F-A)/(abs(A)+abs(F)))